package com.qidian.mes.pro.controller;

import com.qidian.mes.pro.service.ProcessService;
import com.qidian.mes.util.dot.PagerDTO;
import com.qidian.mes.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.qidian.mes.pojo.Process;

import java.util.List;

/**
 * @Author dqy
 * @Description
 * @Time 2024/4/7 16:07
 */
@RestController
@RequestMapping("/process")
@CrossOrigin
public class ProcessController {
    @Autowired
    private ProcessService processService;
    @PostMapping("/saveProcess")
    public QdResult saveProcess(@RequestBody Process process) {
        return processService.saveProcess(process);
    }
    @RequestMapping("/queryAll")
    public QdResult<List<Process>> queryAll() {
        return processService.queryAll();
    }
    @GetMapping ("/queryByPage")
    public QdResult<PagerDTO<Process>> queryByPage(Process process, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit) {
        return processService.queryByPage(process, page, limit);
    }
    @GetMapping("/delete")
    public QdResult deleteProcess(Long processId) {
        return processService.deleteById(processId);
    }
    @GetMapping("/deletes")
    public QdResult deletes(Long [] processIds) {
        return processService.deletes(processIds);
    }
    @PostMapping("/update")
    public QdResult updateProcess(@RequestBody Process process) {
        return processService.updateProcess(process);
    }
    @GetMapping("/queryById")
    public QdResult<Process> queryById(Long processId) {
        return processService.queryById(processId);
    }
}
